package leetcode.code1578;

import leetcode.helper.MaxDebug;

public class Solution extends S1578 {

	@Override
	public int minCost(String s, int[] cost) {
		char[] chars = s.toCharArray();
		int LEN = s.length();
		int ans = 0;
		for (int i = 1; i < LEN; i++) {
			if (chars[i] == chars[i - 1]) {
				int delete = 0;
				if (cost[i] < cost[i - 1]) {
					delete = cost[i];
					cost[i] = cost[i - 1];
				} else {
					delete = cost[i - 1];
				}
				ans += delete;
			}
		}
		return ans;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug65();
		MaxDebug.debug14(so);

	}

}
